<div class="box box-primary">
<div class="">
    <br/>

    <div class="box box-solid">
        <div class="box-body">
            <?php echo form_open(admin_url('manageWallpapers/index'), 'method="get" class=""'); ?>
            <div class="row">
                <div class="col-md-10">

                    <div class="row">
                        <?php $row_ = 'col-xs-12 col-sm-6 col-md-3'; ?>
                        <div class="<?php echo $row_; ?>">
                            <div class="form-group">
                                <label for="q">关键词</label>
                                <input id="q" type="text" class="form-control input-sm"
                                       value="<?php echo($this->input->get('q')); ?>"
                                       name="q">
                            </div>
                        </div>
                        <div class="<?php echo $row_; ?>">
                            <div class="form-group">
                                <label for="category">分类</label>
                                <?php echo form_dropdown('category', array('' => '所有') + ($categories ? $categories : array()), $this->input->get('category'), 'class="form-control input-sm select2" id=""'); ?>
                            </div>
                        </div>
                        <div class="<?php echo $row_; ?>">
                            <div class="form-group">
                                <label for="category">审核状态</label>
                                <?php echo form_dropdown('featured', array('' => '所有') + $featured_dropDown, $this->input->get('featured'), 'class="form-control input-sm select2" id=""'); ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="pull-right">
                        <button type="submit" class="btn btn-primary btn-sm">
                            搜索
                        </button>
                        <a href="<?php echo admin_url('manageWallpapers'); ?>"
                           class="btn btn-info btn-sm">取消</a>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>

            <?php echo form_close(); ?>
        </div>
    </div>
</div>
<div class="bad_words hide"><?php echo json_encode(bad_words_list()); ?></div>
<?php if ($wallpapers) { ?>
    <?php echo form_open(admin_url('manageWallpapers/delete_bulk/' . $offset)); ?>
    <div class="box-body">
        <div>
            <div class="pull-left">
                <a class="btn btn-primary" href="<?php echo admin_url('manageWallpapers/add/') ?>">上传壁纸</a>
                <button
                    onclick="return confirm('Are you sure you want to Delete? these categories and its subcategories')"
                    type="submit"
                    name="delete_bulk" class="btn btn-danger">删除所选
                </button>
            </div>
            <div class="pull-right ul_no_m">
                <?php echo $pagination; ?>
            </div>
        </div>
        <div class="clearfix"></div>
        <br/>

        <div class="table-responsive">
            <table class="table table-striped">
                <tbody>
                <tr>
                    <th style="width: 20px"><input type="checkbox" id="check-all"></th>
                    <th style="width: 10px">#</th>
                    <th style="width: 150px">缩略图</th>
                    <th>壁纸内容</th>
                    <th style="width: 100px;background: #f3f4f5;"></th>
                </tr>
                <?php foreach ($wallpapers as $wallpaper) { ?>
                    <?php $image = $this->image_workshop->crop_image(ORIGINALS_FOLDER_WF . '/' . $wallpaper->wallpaper_image_path, 150, 100, $wallpaper->wallpaper_crop_position, 'thumbnail'); ?>
                    <tr class="ws_<?php echo $wallpaper->wallpaper_seq_id; ?>">
                        <td class="small-col">
                            <input name="wallpaper_id[]" value="<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                   type="checkbox">
                        </td>
                        <td><?php echo $wallpaper->wallpaper_seq_id; ?></td>
                        <td>
                            <div class="img_postions">
                                <img class="thumbnail" src="<?php echo $image; ?>" alt=""/>
                                <?php $positions = $this->image_workshop->positions; ?>
                                <?php foreach ($positions as $po) { ?>
                                    <div class="ap <?php echo $po; ?>">
                                        <input
                                            type="radio" <?php echo($wallpaper->wallpaper_crop_position == $po ? 'checked' : ''); ?>
                                            name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_position]"
                                            value="<?php echo $po; ?>">
                                    </div>
                                <?php } ?>
                            </div>
                            <div>
                                发布时间: <span
                                    class="text-blue"><?php echo timespan(strtotime($wallpaper->wallpaper_date_created)); ?>
                                    以前</span>
                            </div>
                            <div>
                                修改时间: <span
                                    class="text-success"><?php echo($wallpaper->wallpaper_date_modified != '0000-00-00 00:00:00' && $wallpaper->wallpaper_date_modified != NULL ? timespan(strtotime($wallpaper->wallpaper_date_modified)) . ' Ago' : '没有'); ?></span>
                            </div>
                        </td>
                        <td>
                            <div class="row">
                                <div class="col-lg-7">
                                    <div class="single_controls">
                                        <div data-wid="<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                             class="capitalize"><i class="fa fa-font"></i></div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-3">壁纸名称:</div>
                                        <div class="col-sm-9">
                                            <div data-id="name_<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                                 class="content_edit name text-blue" spellcheck="true"
                                                 contenteditable="true"><?php echo $wallpaper->wallpaper_name; ?></div>
                                            <input id="name_<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                                   name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_name]"
                                                   value="<?php echo $wallpaper->wallpaper_name; ?>" type="hidden"/>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-3">短网址:</div>
                                        <div class="col-sm-9">
                                            <div data-id="slug_<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                                 class="content_edit slug text-blue" spellcheck="true"
                                                 contenteditable="true"><?php echo $wallpaper->wallpaper_slug; ?></div>
                                            <input id="slug_<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                                   name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_slug]"
                                                   value="<?php echo $wallpaper->wallpaper_slug; ?>" type="hidden"/>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-3">图片尺寸:</div>
                                        <div class="col-sm-9">
                                            <div style="padding-left: 5px"><span
                                                    class="text-green"><?php echo $wallpaper->wallpaper_width; ?></span>
                                                x <span
                                                    class="text-green"><?php echo $wallpaper->wallpaper_height; ?></span>
                                                <small>
                                                    (<?php echo join(':', getAspectRatio($wallpaper->wallpaper_width, $wallpaper->wallpaper_height)) ?>
                                                    )
                                                </small>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-5">
                                    <div class="form-group">
                                        <?php echo form_dropdown('wall[' . $wallpaper->wallpaper_seq_id . '][category_seq_id]', array('' => 'Parent') + ($categories ? $categories : array()), $wallpaper->category_seq_id, 'class="form-control input-sm select2" id=""'); ?>
                                    </div>
                                    <div class="form-group">
                                        <div>
                                            <label style="padding-left: 0" class="radio-inline">
                                                <input <?php echo($wallpaper->wallpaper_status ? 'checked=""' : ''); ?>
                                                    class="icheck" type="radio"
                                                    name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_status]"
                                                    value="1">
                                                发布
                                            </label>
                                            <label class="radio-inline">
                                                <input <?php echo(!$wallpaper->wallpaper_status ? 'checked=""' : ''); ?>
                                                    class="icheck" type="radio"
                                                    name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_status]"
                                                    value="0">
                                                待审
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <p>
                                            <b>壁纸推荐:</b>
                                            <span class="checkbox-inline">
                                                <input value="1"
                                                    <?php echo($wallpaper->wallpaper_featured ? 'checked=""' : ''); ?>
                                                       name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_featured]"
                                                       type="checkbox"/>
                                            </span>

                                            <span style="padding-left: 10px;"><b>壁纸验收:</b> </span>
                                            <span class="checkbox-inline">
                                                <input value="1"
                                                    <?php echo($wallpaper->wallpaper_approved ? 'checked=""' : ''); ?>
                                                       name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_approved]"
                                                       type="checkbox"/>
                                            </span>
                                        </p>
                                    </div>
                                </div>
                            </div>
                            <div style=" margin-top: 10px; background: #E6E6E6; padding: 5px; ">
                                <div>
                                    <p>标签请用英文 "," <code>隔开，然后回车</code></p>
                                    <input data-role="tagsinput" placeholder="Add tags"
                                           name="wall[<?php echo $wallpaper->wallpaper_seq_id; ?>][wallpaper_tags]"
                                           class="form-control input-sm" value="<?php echo $wallpaper->tags; ?>"
                                           type="text"/>
                                </div>
                            </div>
                        </td>
                        <td style="background: #f3f4f5;">
                            <?php $search_replace = array('{C_SLUG_FULL}' => $wallpaper->cFullSlug, '{C_SLUG}' => $wallpaper->category_slug, '{W_SLUG}' => $wallpaper->wallpaper_slug, '{W_HASH}' => $wallpaper->wallpaper_hash); ?>
                            <?php $front_link = $this->route_links->build_link('wallpaper_page', $search_replace); ?>
                            <div>
                                <a style=" display: block;margin-bottom: 5px " target="_blank"
                                   class="btn btn-xs btn-success view_page_link"
                                   href="<?php echo $front_link ?>"><i class="fa fa-eye"></i> 预览</a>
                            </div>
                            <div>
                                <a style=" display: block;margin-bottom: 5px "
                                   class="btn btn-xs btn-warning view_page_link"
                                   href="<?php echo admin_url('manageWallpapers/edit/' . $wallpaper->wallpaper_seq_id . '/' . $offset); ?>"><i
                                        class="fa fa-pencil"></i> 编辑</a>
                            </div>
                            <div style="margin-top:20px;">
                                <button data-url="<?php echo admin_url('manageWallpapers/save'); ?>"
                                        data-id="ws_<?php echo $wallpaper->wallpaper_seq_id; ?>"
                                        class="btn btn-primary btn-block save_wall" type="button"><i
                                        class="fa fa-save"></i> 保存
                                </button>
                            </div>

                            <div><a style=" display: block;margin-top: 30px " class="btn btn-xs btn-danger"
                                    onclick="return confirm('Are you sure you want to Delete \'<?php echo $wallpaper->wallpaper_name; ?>\'? this will also delete its subcategories')"
                                    href="<?php echo admin_url('manageWallpapers/delete/' . $wallpaper->wallpaper_seq_id . '/' . $offset); ?>"><span
                                        class="glyphicon glyphicon-remove"></span> 删除</a>
                            </div>
                            <div class="ws_<?php echo $wallpaper->wallpaper_seq_id; ?>_load hide"
                                 style="position: relative"><i style="left: 6%; font-size: 38px; margin-top: 17px;"
                                                               class="fa-li fa fa-spinner fa-spin"></i></div>
                        </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="box-footer clearfix">
        <div>
            <div class="pull-left">
                <a class="btn btn-primary" href="<?php echo admin_url('manageWallpapers/add/') ?>">上传壁纸</a>
                <button
                    onclick="return confirm('Are you sure you want to Delete? these categories and its subcategories')"
                    type="submit"
                    name="delete_bulk" class="btn btn-danger">删除所选
                </button>
            </div>
            <div class="pull-right ul_no_m">
                <?php echo $pagination; ?>
            </div>
        </div>
    </div>
    <input type="hidden" name="offset" value="<?php echo $offset; ?>"/>
    <?php echo form_close(); ?>
<?php } else { ?>
    <div class="callout callout-warning">
        <h4>还没有壁纸呢!</h4>

        <p>还没有壁纸呢!你可以点击 <a href="<?php echo admin_url('manageWallpapers/add'); ?>">这里</a>上传壁纸.</p>
    </div>
<?php } ?>
</div>

